import pandas as pd
from pandas import DataFrame

datafile = './文本/客运量_1-1.csv' 
datafile2 = './文本/货运量_1-1.csv'
tempfile = './文本/1_8_temp_k.csv' #统计结果
tempfile2 = './文本/1_8_temp_h.csv' #统计结果

data = pd.DataFrame(pd.read_csv(datafile))
data2 = pd.DataFrame(pd.read_csv(datafile2))

#找到Whole year的值为0的机场
data_sum = data.loc[data['Whole year'] == 0]
data2_sum = data2.loc[data2['Whole year'] == 0]
#以Airport name为索引，计算Year的和，若和为24150，则证明2007-2018年间whole year均为0
DataFrame(data_sum.groupby(data['Airport name'].apply(lambda x:x)).sum()).to_csv(tempfile,encoding = 'utf_8_sig') 
DataFrame(data2_sum.groupby(data2['Airport name'].apply(lambda x:x)).sum()).to_csv(tempfile2,encoding = 'utf_8_sig')